package com.group9.controller;

import com.group9.dto.AddressInfo;
import com.group9.service.ShowAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by 45865 on 2020/6/2.
 */
@Controller
@RequestMapping("show")
public class ShowAddressController {

    @Autowired
    ShowAddressService showAddressService;

    @RequestMapping("address")
    @ResponseBody
    //public List<AddressInfo> showAddress(@RequestBody String loginName){
    public List<AddressInfo> showAddress(HttpSession session){

        String loginName = (String) session.getAttribute("loginName");
        System.out.println(loginName);
        List<AddressInfo> addressInfoList = showAddressService.addressList(loginName);
        if (null != addressInfoList){
            return addressInfoList;
        }else {
            return null;
        }

    }
}
